$(document).ready(function() {
	$("#ajaxfresh").click(function() {
		ajaxFresh();
	})
	$("#ajaxsubmit").click(function() {
		ajaxSubmit();
	})
})
function ajaxFresh() {
	$.get("ajaxlist", function(data, status) {
		if (status == "success") {
			$("#content").empty();
			for (var i = 0; i < data.length; ++i) {
				var row = document.createElement("tr");
				var id = document.createElement("td");
				var name = document.createElement("td");
				var age = document.createElement("td");
				id.textContent = data[i]["id"];
				name.textContent = data[i]["name"];
				age.textContent = data[i]["age"];
				row.appendChild(id);
				row.appendChild(name);
				row.appendChild(age);
				$("#content").append(row);
			}
		}
	})
}
function ajaxSubmit() {
	$.post("ajaxupdate", {
		name : $("#name").val(),
		age : $("#age").val()
	}, function(data, status) {
		if (status == "success") {
			$("#tips").show(function() {
				$("#tips").fadeOut(5000)
			})
			ajaxFresh();
		}
	})
}